﻿#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <Windows.h>
#include <iostream>

#include "putText.h"

using namespace std;
using namespace cv;

constexpr auto width = 600;
constexpr auto zhFont = "微软雅黑";
constexpr auto enFont = "Arial";

// 声明一个快速绘制的方法：
void MyEllipse(Mat img, double angle);
void MyFilledCircle(Mat img, Point center);
void MyLine(Mat img, Point start, Point end);
int main(void) {
	// 设置窗口名：
	char window[] = "Show Window";
	// 生成指定类型的零矩阵：
	/***********************
	* CV_<bit_depth>(S|U|F)C<number_of_channels>
	* bit_depth: 比特数 - 代表8bite\16bite\32bite\64bite
	* S: signed int，即有符号整型；U: unsigned int，即无符号整型；F: float，单精度浮点型。
	* C<number_of_channels>：所存储的图片的通道数。
	* eg: 1 - grayImg灰度图像-单通道图像
	*     2 - RGB彩色图像-3通道图像
	*     3 - 带Alpha通道的RGB彩色图像-4通道图像
	***********************/
	Mat image = Mat::zeros(width, width, CV_8UC3);
	// 小动画：
	int angle = 180;
	putTextZH(image, "这是一串中文字符串！", Point(300, 10), Scalar(255, 255, 255), 20, zhFont, false, false);
	putTextZH(image, "Scalar(255,0,0)", Point(0, 10), Scalar(255, 0, 0), 20, enFont, false, false);
	putTextZH(image, "Scalar(0,255,0)", Point(0, 30), Scalar(0, 255, 0), 20, enFont, false, false);
	putTextZH(image, "Scalar(0,0,255)", Point(0, 50), Scalar(0, 0, 255), 20, enFont, false, false);
	while (angle <= 360)
	{
		MyEllipse(image, angle);
		imshow(window, image);
		angle += 10;
		waitKey(100);
	}
	MyFilledCircle(image, Point(width / 2, width / 2));
	imshow(window, image);
	waitKey(1000);
	
	// 保存图片：
	imwrite("./Image.png", image);
	waitKey(0);
	return(0);
}

void MyEllipse(Mat img, double angle)
{
	int thickness = 2;
	int lineType = LINE_AA;
	ellipse(img,
		Point(width / 2, width / 2),
		Size(width / 4, width / 16),
		angle,
		0,
		360,
		Scalar(255, 0, 0),
		thickness,
		lineType);
}
void MyFilledCircle(Mat img, Point center)
{
	circle(img,
		center,
		width / 32,
		Scalar(0, 0, 255),
		FILLED,
		LINE_AA);
}
void MyLine(Mat img, Point start, Point end)
{
	int thickness = 2;
	int lineType = LINE_AA;
	line(img,
		start,
		end,
		Scalar(0, 0, 0),
		thickness,
		lineType);
}